package com.ruoyi.common.aliyun;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;

import lombok.Data;

/**
 *	支付宝支付Config
 * @author liuz
 */
@Data
@Component
public class AlipayConfig {

	@Value("${alipay.config.gateway}")
	private String gateway;
	@Value("${alipay.config.appId}")
	private String appId;
	@Value("${alipay.config.appPrivateKey}")
	private String appPrivateKey;
	@Value("${alipay.config.alipayPublicKey}")
	private String alipayPublicKey;
	
	@Value("${alipay.config.publicCertPath}")
	private String appCertPublicKey;
	
	@Value("${alipay.config.publicCertRAS2Path}")
	private String alipayCertPublicKeyRSA2;
	
	@Value("${alipay.config.RootCertPath}")
	private String alipayRootCert;
	

	// 异步回调地址
	@Value("${alipay.config.notifyUrl}")
	private String notifyUrl;

	@Bean
	public AlipayClient getAlipayClient(){
		return new DefaultAlipayClient(this.getGateway() ,
				this.getAppId() ,
				this.getAppPrivateKey() ,
				"json" ,
				"UTF-8" ,
				this.getAlipayPublicKey() ,
				"RSA2");
	}
}
